import type {
  ListResult,
  {{ properCase modelName }}CreateRequest,
  {{ properCase modelName }}Filter,
  {{ properCase modelName }}Type,
} from "@/api/types";
import request from "@/api/request";

const list = (filter: {{ properCase modelName }}Filter): Promise<ListResult<{{ properCase modelName }}Type>> => {
  return request.get("/{{ camelCase modelName }}s", {
    params: filter,
  });
};

const create = ({{ camelCase modelName }}CreateRequest: {{ properCase modelName }}CreateRequest): Promise<{{ properCase modelName }}Type> => {
  return request.post("/{{ camelCase modelName }}s", {{ camelCase modelName }}CreateRequest);
};

// Todo:
const edit = (
  id: string,
  {{ camelCase modelName }}EditRequest: {{ properCase modelName }}CreateRequest
): Promise<{{ properCase modelName }}Type> => {
  return request.post(`/{{ camelCase modelName }}s/${id}`, {{ camelCase modelName }}EditRequest);
};

export default {
  list,
  create,
  edit,
};
